﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace enkeltcp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        public class Person
        {
            public string Name { get; set; }
            public string Personnummer { get; set; }
            public string Weight { get; set; }
            public Person(string name, string p, string w)
            {
                Name = name;
                Personnummer = p;
                Weight = w;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            
            var client = new UdpClient();
           
            
            IPEndPoint ep = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 9059);
            client.Connect(ep);
            Byte[] sendBytes = Encoding.ASCII.GetBytes(Convert.ToString(textBox1.Text));
             
            client.Send(sendBytes,sendBytes.Length);
            
            var receive = client.Receive(ref ep);
            label1.Text = "Medelande från servern: " + ep.Address + "; " + ep.Port;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
